#include <iostream>
#include <vector>
using namespace std;

class Solution 
{
public:
    int peakIndexInMountainArray(vector<int>& arr) 
	{
		int left = 1, right = arr.size() - 2;
		while (left < right)
		{
			int mid = left + (right - left + 1) / 2;
			if (arr[mid] > arr[mid - 1]) left = mid;
			else if (arr[mid] < arr[mid - 1]) right = mid - 1;
		}
		return left;
    }
};

void Test01()
{
	vector<int> nums = { 0, 2, 1, 0 };
	Solution s;
	cout << s.peakIndexInMountainArray(nums);
}

int main()
{
	Test01();
	return 0;
}